package titt;

import titt.util.Bytes;

public class TITTValues { 
	//TITT is Totally Transparent
	protected TITTValues() {}
	
	public static final String 	PREFIX_CALLBACK = "callback";
	
	public static final int		NUDER_IO_TIMEOUT = 10;
	
	public static final int 	GET = 0,
								POST = 1,
								OPTIONS = 2;
	
	public static final byte[] 	GET_BYTES 	= 	Bytes.asBytes("GET"),
								POST_BYTES 	= 	Bytes.asBytes("POST"),
								HTTP_BYTES 	= 	Bytes.asBytes("HTTP"),
								OPTIONS_BYTES = Bytes.asBytes("OPTIONS");
	
	public static final byte[] 	HTTP_NEWLINE = { 13 , 10 };
	public static final int	   	HTTP_NEWLINE_LENGTH = HTTP_NEWLINE.length;
	public static final String 	HTTP_NEWLINE_STRING = Bytes.asString(HTTP_NEWLINE);
	
	public static final String 	MULTIPART_SEPERATOR = "--";
	
	public static String methodAsString(int method) {
		switch (method) {
		case GET:
			return "GET";
		default:
			return "POST";
		}
	}
	
	public static String getResponse(int statusCode) {
		String v = "HTTP/1.1 ";
		switch (statusCode) {
		case 200:
			return v + "200 OK";
		case 206:
			return v + "206 Partial content";
		case 307:
			return v + "307 Temporary Redirect";
		case 400:
			return v + "400 Bad Request";
		case 409:
			return v + "409 Conflict";
		case 416:
			return v + "416 Requested Range Not Satisfiable";
		case 404:
			return v + "404 Not Found";
		case 411:
			return v + "411 Length Required";
		case 418:
			return v + "418 I'm a teapot";
		case 423:
			return v + "423 Locked";
		case 503:
			return v + "503 Service Unavailable";
		default:
			return v + "200 OK";
		}
	}
}
